<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/sprint/template.xhtml"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="main-content">

        <!-- ************************ agreagar tarea ********************* -->

        <h:form id="agregarTareaNueva">
            <br></br>
            <h3><h:outputText value="#{msgs.backlogScrum}"/></h3><br/>
            <p:commandButton id="showDialogButton" type="button" value="#{msgs.nuevaTarea}" onclick="dlg.show()" />
        </h:form>	
        <p:dialog header="#{msgs.nuevaTarea}" widgetVar="dlg" resizable="false">
            <h:form id="formNuevaTarea">

                <h:panelGrid columns="6" style="margin-bottom:10px">

                    <h:outputLabel value="#{msgs.descripcion}: "/>
                    <h:inputText value="#{nuevaTareaBean.des}"/>

                    <h:outputLabel value="#{msgs.tipo}: "/>
                    <h:selectOneMenu id="selectTipoTarea" value="#{nuevaTareaBean.tipo}">
                        <f:selectItems value="#{listadoTiposTareasBean.listado}"/>
                    </h:selectOneMenu>
                </h:panelGrid>

                <p:commandButton id="guargarButton" value="#{msgs.guardar}" action="#{nuevaTareaBean.submit}" update=":display" oncomplete="dlg.hide();"/>

            </h:form>
        </p:dialog>


        <!-- ************************ asignar esfuerzo ********************* -->

        <p:dialog header="#{msgs.estimacion}" widgetVar="dlgEsfuerzo" resizable="false">
            <h:form id="formEsfuerzo">

                <h:panelGrid columns="2" style="margin-bottom:10px">

                    <h:outputLabel value="#{msgs.esfuerzo}: "/>
                    <h:inputText value="#{backlogBean.esfuerzo}"/>

                </h:panelGrid>

                <p:commandButton id="guargarButton" value="#{msgs.guardar}" action="#{backlogBean.guardarEsfuerzo}" update="@all" oncomplete="dlgEsfuerzo.hide();"/>

            </h:form>
        </p:dialog>


        <!-- ************************ asignar tarea a sprint ********************* -->

        <p:dialog header="#{msgs.agregarTareaSprint}" widgetVar="asignarDialog" resizable="false" > 


            <h:form id="formAsignarTarea">

                <h:panelGrid  columns="6" style="margin-bottom:10px">

                    <h:outputLabel value="#{msgs.asignadaA}: "/>
                    <h:selectOneMenu id="selectTipoTarea" value="#{backlogBean.colaborador}">
                        <f:selectItems value="#{listadoMiembrosBean.listado}"/>
                    </h:selectOneMenu>
                </h:panelGrid>

                <p:commandButton id="asignartButton" value="#{msgs.asignar}" action="#{backlogBean.asignar}" update="@all"  oncomplete="asignarDialog.hide();"/>

            </h:form>
        </p:dialog>  


        <!-- ************************ TABLA tareas ********************* -->

        <p:outputPanel id="display"  style="display:block;margin-top:10px;">

            <h:form id="formtable"> 

                <p:contextMenu for="backlog">
                    <p:menuitem value="#{msgs.agregarSprint}"  update="backlog" icon="ui-icon-gear" oncomplete="asignarDialog.show()"/>

                    <p:menuitem value="#{msgs.asignarEsfuerzo}"  update="backlog" icon="ui-icon-gear" oncomplete="dlgEsfuerzo.show()"/>
                    <p:menuitem value="#{msgs.eliminar}" update="backlog" icon="ui-icon-close" actionListener="#{backlogBean.deleteTarea}"/>
                        
                </p:contextMenu>

                <p:dataTable id="backlog" var="tarea" value="#{backlogBean.listado}" rowKey="#{tarea.id}"
                             selection="#{productoSeleccionadoBean.tareaActual}" selectionMode="single">

                    <f:facet name="header">
                        <h:outputText value="#{msgs.backlog}"/>
                    </f:facet>
                    <p:column headerText="#{msgs.numeroAbreviado}" >
                        #{tarea.id}
                    </p:column>

                    <p:column headerText="#{msgs.tarea}" >
                        #{tarea.des}
                    </p:column>
                    <p:column headerText="#{msgs.tipo}" >
                        #{tarea.idTiptareaFk}
                    </p:column>
                    <p:column headerText="#{msgs.fechaInicio}" >
                        <h:outputText value="#{tarea.fecini}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                    </p:column>

                    <p:column headerText="#{msgs.fechaFin}" >
                        <h:outputText value="#{tarea.fecfin}">
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>
                    </p:column>
                    <p:column headerText="#{msgs.estado}" >
                        #{tarea.idEstadoFk}
                    </p:column>
                    <p:column headerText="#{msgs.colaborador}" >
                        #{tarea.idColaboradorFk.nombre}
                    </p:column>

                </p:dataTable> 

            </h:form> 

        </p:outputPanel>
    </ui:define> 
</ui:composition>

